1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
"use client"
import * as React from "react"
import { useRouter } from "next/navigation"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
import { Eye } from "lucide-react"
import { GeneralContractListItem } from "@/lib/general-contracts/main/general-contracts-table-columns"
interface VendorGeneralContractReviewTableProps {
data: GeneralContractListItem[]
}
function getStatusBadge(status: string) {
const statusLabels: Record<string, string> = {
'Draft': '임시저장',
'Request to Review': '조건검토요청',
'Vendor Replied Review': '협력업체 회신',
'SHI Confirmed Review': '당사 검토 확정',
'Contract Accept Request': '계약승인요청',
'Complete the Contract': '계약체결',
'Reject to Accept Contract': '계약승인거절',
'Contract Delete': '계약폐기',
}
const statusColors: Record<string, "default" | "secondary" | "destructive" | "outline"> = {
'Request to Review': 'secondary',
'Vendor Replied Review': 'default',
'SHI Confirmed Review': 'default',
}
const label = statusLabels[status] || status
const variant = statusColors[status] || 'outline'
return <Badge variant={variant}>{label}</Badge>
}
function getFormattedDate(dateString: string | null | undefined) {
if (!dateString) return "-"
try {
return new Intl.DateTimeFormat("ko-KR", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).format(new Date(dateString))
} catch {
return "-"
}
}
function getFormattedDateRange(startDate: string | null | undefined, endDate: string | null | undefined) {
if (!startDate && !endDate) return "-"
const start = startDate ? getFormattedDate(startDate) : "-"
const end = endDate ? getFormattedDate(endDate) : "-"
return `${start} ~ ${end}`
}
export function VendorGeneralContractReviewTable({ data }: VendorGeneralContractReviewTableProps) {
const router = useRouter()
return (
<Card>
<CardHeader>
<CardTitle>조건검토 계약 목록</CardTitle>
</CardHeader>
<CardContent className="p-0">
<Table>
<TableHeader>
<TableRow>
<TableHead>계약번호</TableHead>
<TableHead>계약명</TableHead>
<TableHead>상태</TableHead>
<TableHead>계약기간</TableHead>
<TableHead>등록일</TableHead>
<TableHead>작업</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{data.length === 0 ? (
<TableRow>
<TableCell colSpan={6} className="text-center py-8 text-muted-foreground">
조건검토 요청된 계약이 없습니다.
</TableCell>
</TableRow>
) : (
data.map((contract) => (
<TableRow key={contract.id}>
<TableCell>
<div className="font-medium">
{contract.contractNumber}
{contract.revision > 0 && (
<span className="text-muted-foreground ml-1">
(Rev.{contract.revision})
</span>
)}
</div>
</TableCell>
<TableCell>
<div className="max-w-[300px] truncate">
{contract.name || "-"}
</div>
</TableCell>
<TableCell>
{getStatusBadge(contract.status)}
</TableCell>
<TableCell>
{getFormattedDateRange(contract.startDate, contract.endDate)}
</TableCell>
<TableCell>
{getFormattedDate(contract.registeredAt)}
</TableCell>
<TableCell>
<Button
variant="ghost"
size="sm"
onClick={() => {
router.push(`/partners/general-contract-review/${contract.id}`)
}}
>
<Eye className="h-4 w-4 mr-2" />
조회
</Button>
</TableCell>
</TableRow>
))
)}
</TableBody>
</Table>
</CardContent>
</Card>
)
}
|